package cn.tedu.carehome.foundation.controller;
import cn.tedu.carehome.foundation.unti.QRCodeGenerator;
import cn.tedu.carehome.foundation.web.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;


@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/api/common")
public class QcodeController {
    private String path;
    @GetMapping("/QRCode")
    public JsonResult<Void>  createqrcode(){
        try {
            String QR_CODE_IMAGE_PATH = path+"MyQRCode.png";
            String QR_CODE_TEXT = "https://baidu.com";
            QRCodeGenerator.generateQRCodeImage(QR_CODE_TEXT, 350, 350, QR_CODE_IMAGE_PATH);

            return JsonResult.ok();
        } catch (Exception e) {
            log.error(e.toString());
            return JsonResult.ok();
        }
    }
}
